exports.request = function(app, queryResponse, ypaging,paging,io) {
  io.on('connection', function (socket) {
    setInterval(function () {
      var cpu = Math.round(Math.random()*30+30);
      var ram = Math.round(Math.random() * 100);
      var disk = Math.round(Math.random() * 100);
      var network = Math.round(Math.random() * 100);
      var obj = {
        data:{
          cpu: cpu,
          ram: ram,
          disk: disk,
          network: network
        }
      };
      io.emit('sysSourceUseRate',obj);
    },2000);
  });
  
  //告警统计分析-->查询告警数
  app.post('/sas/faultLocation/appAlarms/queryAlarmNums', function(req, res) {
    res.send(queryResponse.queryAlarmNums);
  });
  //告警统计分析-->查询告警数-->下钻
  app.post('/sas/faultLocation/appAlarms/queryDetAlarmNums', function(req, res) {
    res.send(queryResponse.queryDetAlarmNums);
  });
  //告警统计分析-->查询可用/被过滤告警数
  app.post('/sas/faultLocation/appAlarms/queryStrainAppAlarmNum', function(req, res) {
    res.send(queryResponse.queryStrainAppAlarmNum);
  });
  //查询交易总量
  app.post('/sas/Omdisplay/sysBusinessStatistics/sumStatisticsQuery', function(req, res) {
    if (req.body.tradeStateCode.length === 0) {
      res.send(queryResponse.totalAmount);
    } else {
      res.send(queryResponse.diffPro);
    }
  });

  //告警级别查询
  app.post('/sas/faultLocation/appAlarms/alarmLevelQuery', function(req, res) {
    res.send(queryResponse.alarmLevel);
  });
  //告警状态查询
  app.post('/sas/faultLocation/appAlarms/alarmStateQuery', function(req, res) {
    res.send(queryResponse.alarmState);
  });
  //下钻
  app.post('/sas/faultLocation/appAlarms/down', function(req, res) {
    var down = ypaging(req.body, queryResponse.appAlarmNum.data.lineData);
    res.send(down);
  });
  //查询应用告警数
  app.post('/sas/faultLocation/appAlarms/query', function(req, res) {
    // var appAlarms = paging(req.body,queryResponse.appAlarms.data);
    res.send(queryResponse.appAlarms);
  });
  //应用告警数的下钻
  app.post('/sas/faultLocation/appAlarms/alarmNumQuery', function(req, res) {
    res.send(queryResponse.alarmNumQuery);
  });
  app.post('/sas/faultLocation/appAnalysis/query', function(req, res) {
    res.send(queryResponse.analysisNum);
  });
  //可用，被过滤查询
  app.post('/sas/faultLocation/appAlarms/comparison', function(req, res) {
    res.send(queryResponse.appAlarmsStrian);
  });
  //成功率
  app.post('/sas/Omdisplay/TransactionSuccessRate/querySuccessRate', function(req, res) {
    res.send(queryResponse.querySuccessRate);
  });
  //系统告警数据挖掘
  app.post('/sas/resourceMonitoring/query', function(req, res) {
    
    // var alarms = paging(req.body,queryResponse.queryrRMNum.data);
    res.send(queryResponse.queryrRMNum);
  });
  //运维开发工作情况分析-->查询交易渠道问题数
  app.post('/sas/OMdisplay/omWork', function(req, res) {
    res.send(queryResponse.queryChannelProblem);
  });
  //运维开发工作情况分析-->查询各业务问题数对比
  app.post('/sas/OMdisplay/businessContrast', function(req, res) {
    res.send(queryResponse.businessContrast);
  });
  //运维开发工作情况分析-->查询各渠道问题数对比
  app.post('/sas/OMdisplay/channelContrast', function(req, res) {
    res.send(queryResponse.channelContrast);
  });
  app.post('/sas/OMdisplay/omWork', function(req, res) {
    res.send(queryResponse.queryChannelProblem);
  });
  //运维开发工作情况分析-->查询交易渠道开发数
  app.post('/sas/OMdisplay/devWork', function(req, res) {
    res.send(queryResponse.queryDevelopNum);
  });
  //运维开发工作情况分析-->运维开发完成情况
  app.post('/sas/OMdisplay/devComplete', function(req, res) {
    res.send(queryResponse.devComplete);
  });
  //运维开发工作情况分析-->运维开发完成占比
  app.post('/sas/OMdisplay/devProportion', function(req, res) {
    res.send(queryResponse.devProportion);
  });
  //运维开发工作情况分析-->渠道开发分配
  app.post('/sas/OMdisplay/devChnlDuty', function(req, res) {
    res.send(queryResponse.devChnlDuty);
  });
  //运维开发工作情况分析-->开发人员问题数对比
  app.post('/sas/OMdisplay/developerContrast', function(req, res) {
    res.send(queryResponse.developerContrast);
  });
  //系统上线变更情况分析
  app.post('/sas/OMdisplay/sysOnlineChange', function(req, res) {
    res.send(queryResponse.sysOnlineChange);
  });
  //系统上线变更情况分析详细
  app.post('/sas/OMdisplay/sysOnlineChangeDet', function(req, res) {
    res.send(queryResponse.sysOnlineChangeDet);
  });
  //物连网业务交易成功率查询
  app.post('/sas/sysServiceData/pboss/pbossProvsSuccessRate', function(req, res) {
    res.send(queryResponse.pbossProvsSuccessRate);
  });
  //物连网业务交易成功率表格详细查询
  app.post('/sas/sysServiceData/pboss/pbossProvsSuccessRateDetail', function(req, res) {
    res.send(queryResponse.pbossProvsSuccessRateDetail);
  });
  //统一支付佣金结算准备率
  app.post('/sas/sysServiceData/Upay/UpayCSAScore', function(req, res) {
    res.send(queryResponse.UpayCSAScore);
  });
  //统一支付佣金结算准备率表格详细查询
  app.post('/sas/sysServiceData/Upay/UpayCSAScoreDet', function(req, res) {
    res.send(queryResponse.UpayCSAScoreDet);
  });
  //主机整体信息展示
  app.post('/sas/resourceMonitoring/hostMessage/hostWholeInfo', function(req, res) {
    res.send(queryResponse.hostWholeInfo);
  });
  //主机整体信息展示表格下钻到图
  app.post('/sas/resourceMonitoring/hostMessage/hostWholeDetail', function(req, res) {
    res.send(queryResponse.hostWholeDetail);
  });
  //主机详细信息展示
  app.post('/sas/resourceMonitoring/hostdetMessage/hostInfo', function(req, res) {
    res.send(queryResponse.hostInfo);
  });
  //主机详细信息状态展示
  app.post('/sas/resourceMonitoring/hostdetMessage/hostState', function(req, res) {
    res.send(queryResponse.hostState);
  });
  //主机详细信息进程展示
  app.post('/sas/resourceMonitoring/hostdetMessage/hostProcess', function(req, res) {
    res.send(queryResponse.hostProcess);
  });
  //主机详细信息资源展示
  app.post('/sas/resourceMonitoring/hostdetMessage/hostResource', function(req, res) {
    res.send(queryResponse.hostResource);
  });
  //主机详细信息组件展示
  app.post('/sas/resourceMonitoring/hostdetMessage/hostComponent', function(req, res) {
    res.send(queryResponse.hostComponent);
  });
  //主机详细信息状态展示-->硬盘下钻
  app.post('/sas/resourceMonitoring/hostdetMessage/diskNat', function(req, res) {
    res.send(queryResponse.diskNat);
  });
  //主机详细信息状态展示-->内存下钻
  app.post('/sas/resourceMonitoring/hostdetMessage/ramNat', function(req, res) {
    res.send(queryResponse.ramNat);
  });
  //主机详细信息状态展示-->网络下钻
  app.post('/sas/resourceMonitoring/hostdetMessage/interNat', function(req, res) {
    res.send(queryResponse.interNat);
  });
  //主机详细信息状态展示-->cpu下钻
  app.post('/sas/resourceMonitoring/hostdetMessage/cpuNat', function(req, res) {
    res.send(queryResponse.cpuNat);
  });
  //网络设备资源使用率-->防火墙
  app.post('/sas/OMdisplay/usageRate/networkFailwall', function(req, res) {
    res.send(queryResponse.networkFailwall);
  });
  //网络设备资源使用率-->器由器
  app.post('/sas/OMdisplay/usageRate/networkRouter', function(req, res) {
    res.send(queryResponse.networkRouter);
  });
  //网络设备资源使用率-->交换机
  app.post('/sas/OMdisplay/usageRate/networkExchangeMachine', function(req, res) {
    res.send(queryResponse.networkRouter);
  });
  //角色授权
  app.post('/sas/sysMng/role/moduleBind', function(req, res) {
    res.send({
      state: '10000',
      message: '保存成功'
    });
  });
  app.post('/sas/sysMng/role/query', function(req, res) {
    // var resBody = paging(req.body,queryResponse.role);
    res.send(queryResponse.role);
  });
  app.post('/sas/sysMng/roleMng/modulesQuery', function(req, res) {
    res.send(queryResponse.modules)
  });
  //下拉框角色查询
  app.get('/sas/sysMng/role/roleQuery', function(req, res) {
    res.send(queryResponse.roleData);
  });
  //个人页面定制
  app.post('/sas/sysMng/user/habitQuery',function(req,res){
    res.send(queryResponse.habitQuery);
  });
  //保存
  app.post('/sas/sysMng/user/habitSave',function(req,res){
    res.send(queryResponse.habitSave);
  });
  //物联网业务交易成功达标率 -->明细表
  app.post('/sas/sysServiceData/pboss/pbossProvsSuccessRateTableDetail',function(req,res){
    res.send(queryResponse.pbossProvsSuccessRateTableDetail);
  });
  //统一支付佣金结算准确率 -->明细表
  app.post('/sas/sysServiceData/uPay/UpayCSAScoreTable',function(req,res){
    res.send(queryResponse.UpayCSAScoreTable);
  });
  //清结算系统业务处理时长数据展示  --> 图
  app.post('/sas/analysisSysOM/cleanCount/queryHandlingTimeShow',function(req,res){
    res.send(queryResponse.queryHandlingTimeShow);
  });
  //清结算业务类型
  app.get('/sas/analysisSysOM/cleanCount/queryCCBusinessType',function(req,res){
    res.send(queryResponse.queryCCBusinessType);
  });
  //处理时长趋势分析
  app.post('/sas/analysisSysOM/cleanCount/queryTimeTrendAnalysis',function(req,res){
    if(req.body.weekOrMonth === 'w'){
      res.send(queryResponse.queryTimeTrendAnalysisWeek);
    }else {
      res.send(queryResponse.queryTimeTrendAnalysisMonth);
    }
  });
  //清结算一次完成结算成功率
  app.post('/sas/analysisSysOM/cleanCount/queryFinishSuccessRate',function(req,res){
    res.send(queryResponse.queryFinishSuccessRate);
  });
  //变更管理
  app.post('/sas/workOrderData/changeMgmt/query',function(req,res){
    var code =  req.body.measureIndexCode;
    if(code === 'h1001'){//变更来源
      res.send(queryResponse.changeMgmtQuery);
    }else if(code === 'h1003'){//变更影响度
      res.send(queryResponse.changeMgmtQuery1);
    }else if(code === 'h1004'){//变更紧急度
      res.send(queryResponse.changeMgmtQuery2);
    }else if(code === 'h1005'){//风险等级
      res.send(queryResponse.changeMgmtQuery3);
    }else if(code === 'h1002'){//变更实施结果
      res.send(queryResponse.changeMgmtQuery4);
    }else{//变更成功率
      if(req.body.changeTypeCode === '1'){
        res.send(queryResponse.changeMgmtQuery5);
      }else {
        res.send(queryResponse.changeMgmtQuery6);
      }
    }
  });
   //事件管理 --> 单月事件单统计
  app.post('/sas/workOrderData/eventMgmt/query',function(req,res){
    var code = req.body.measureIndexCode;
    if(code === 'h2004' || code === 'h2005' || code === 'h2006'){
      res.send(queryResponse.eventMgmtQuery2);
    }else if(code === 'h2007' || code === 'h2008'){
      res.send(queryResponse.eventMgmtQuery1);
    }else {
      res.send(queryResponse.eventMgmtQuery);
    }
  });
  //事件管理 -->事件单趋势统计
  app.post('/sas/workOrderData/eventTrend/query',function(req,res){
    var code = req.body.measureIndexCode;
    // if(code === '1'){
      res.send(queryResponse.eventTrendQuery);
    // }
  });
  //问题管理 -->单月问题单统计
  app.post('/sas/workOrderData/problemMgmt/query',function(req,res){
    var code = req.body.measureIndexCode;
    if(code === '15601'){
      if(req.body.changeTypeCode === '1'){
        res.send(queryResponse.problemMgmtQuery);
      }else {
        res.send(queryResponse.problemMgmtQuery1);
      }
    }else{
      res.send(queryResponse.problemMgmtQuery2);
    }
  });
  //问题管理 --> 问题单趋势统计
  app.post('/sas/workOrderData/problemTrend/query',function(req,res){
    res.send(queryResponse.problemTrendQuery);
  });
  //发布管理 --> 当月发布管理统计
  app.post('/sas/workOrderData/publishMgmt/query',function(req,res){
    var code = req.body.measureIndexCode;
    if(code === 'h5001'){
      res.send(queryResponse.publishMgmtQuery);
    }else {
      res.send(queryResponse.publishMgmtQuery1);
    }
  });
  app.post('/sas/workOrderData/publishVersionTrend/query',function(req,res){
    res.send(queryResponse.publishVersionTrendQuery);
  });
  //工单使用和处理分析
  app.post('/sas/workOrderData/useAndHandleCondition/query',function(req,res){
    res.send(queryResponse.auditDataQuery);
  });
};